Conversation
d-zaytsev
reviewed
Oct 15, 2025
Comment on lines
15
to
51
| def generate_cosmic_name(): | ||
| """Generates unique cosmic object name with timestamp""" | ||
| cosmic_objects = [ | ||
| "Комета", | ||
| "Звезда", | ||
| "Галактика", | ||
| "Туманность", | ||
| "Спутник", | ||
| "Вселенная", | ||
| "Астероид", | ||
| "Планета", | ||
| "Метеорит", | ||
| "Квазар", | ||
| "Пульсар", | ||
| "Чёрная дыра", | ||
| "Суперновая", | ||
| "Созвездие", | ||
| "Космодром", | ||
| "Телескоп", | ||
| "Ракета", | ||
| "Орбита", | ||
| "Экзопланета", | ||
| "Космический корабль", | ||
| "Межзвёздный объект", | ||
| "Космическая станция", | ||
| "Темная материя", | ||
| "Космический зонд", | ||
| ] | ||
| prefixes = ["", "XB-", "NGC-", "HD-", "M-", "IC-", "PG-", "PSR-"] | ||
|
|
||
| timestamp = datetime.now().strftime("%d%m%y") | ||
| random_num = random.randint(100, 999) | ||
|
|
||
| cosmic_type = random.choice(cosmic_objects) | ||
| prefix = random.choice(prefixes) | ||
|
|
||
| return f"{cosmic_type} {prefix}{timestamp}{random_num}" |
Contributor
There was a problem hiding this comment.
Может лучше из файла читать их какого-то, а то функция на 40 строчек почти
|
|
||
| guid = db.Column(Text, nullable=False, unique=True) | ||
| title = db.Column(Text, default="Новая сеть", nullable=False) | ||
| title = db.Column(Text, default=lambda: generate_cosmic_name(), nullable=False) |
Contributor
There was a problem hiding this comment.
Тут точно лямбда нужна? Нельзя просто default= generate_cosmic_name, если функцию передавать надо?
Collaborator
Author
There was a problem hiding this comment.
Да, иначе результат функции он кеширует и при создании сети каждый раз будет одно и то же название. Лямбда же позволяет при каждом создании сети вызывать функцию
Contributor
There was a problem hiding this comment.
Так если default= generate_cosmic_name использовать, мы тоже чисто функцию передаём, нет?
Collaborator
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create unique cosmic name for new net (#292)
Fix README mistake